package designpattern.factory;

import designpattern.dao.NewsDao;
import designpattern.dao.impl.NewsDaoImpl;
import designpattern.dao.impl.NewsDaoMySqlImpl;
import designpattern.dao.impl.NewsDaoOracleImpl;
import designpattern.dao.impl.NewsDaoRedisImpl;

/**
 * @author 吴阳基
 * @datetime 2024/1/6 8:36
 */
public class SimpleDaoFactory {
    public static NewsDao getInstance() {

        return new NewsDaoImpl();

    }

    public static NewsDao getInstance(String key) {
        switch (key) {
            case "mysql":
                return new NewsDaoMySqlImpl();
            case "oracle":
                return new NewsDaoOracleImpl();
            case "redis":
                return new NewsDaoRedisImpl();
            default:
                throw new RuntimeException("不支持的数据库类型：" + key);
        }

    }
}
